package com.situ.blog.service.impl;


import com.situ.blog.dao.IBlogDao;
import com.situ.blog.dao.impl.BlogDaoImpl;
import com.situ.blog.pojo.entity.Blog;
import com.situ.blog.pojo.query.BlogQuery;
import com.situ.blog.service.IBlogService;
import com.situ.blog.util.LayUITableResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BlogServiceImpl implements IBlogService {
    @Autowired
    private IBlogDao blogDao;

    //业务：为了封装PageInfo，查询两次数据库
    @Override
    public LayUITableResult selectByPage(BlogQuery blogQuery) {
        List<Blog> list = blogDao.selectByPage(blogQuery);
        Integer totalCount = blogDao.selectTotalCount(blogQuery);

        return LayUITableResult.ok(totalCount, list);
    }

    @Override
    public void deleteById(Blog blog) {
        blogDao.deleteById(blog);
    }

    @Override
    public void add(Blog blog) {
        blogDao.add(blog);
    }

    @Override
    public void updateStatus(Blog blog) {
        blogDao.updateStatus(blog);
    }
}
